import gettime from './getdateTime.js'
// 在每次运行时检查数据并修改处于(已下单)状态下的采购订单状态
function changstate(){
	var time = gettime.dateTimeStr().substring(0,10);
	var arr = []
	uni.request({
		url:'api/procurerecord/getidbystate',
		method:'POST',
		data:{state:'已下单'},
		success(res) {
			let reg = new RegExp('-', 'g')
			for(var i=0;i<res.data.length;i++){
				if(((new Date(time.replace(reg, '/'))) > (new Date(res.data[i].data.substring(0,10).replace(reg, '/'))))){
					uni.request({
						url:'api/procurerecord/upstate',
						method:"PUT",
						data:{state:'待收货',id:res.data[i].id},
					})
				}
			}
		}
	})
	// console.log("o")
}

module.exports = {
	changstate
}